import { Item } from "../../shared/face/index";
import { BaseBody } from '../../core/rpg';
import { BagFuncResult } from './types';
import { ComType } from "../../core/tool/component";
import base_component from "../../component/base_component";

/**
 * ChangePlayerShow 功能 修改玩家形象图片
 * @param useItem 使用的物品
 * @param useCount 使用数量
 * @param funcData 函数数据
 * @param player 玩家对象
 * @returns 使用结果
 */
export async function ChangePlayerShow(useItem: Item, useCount: number, funcData: any, player: BaseBody): Promise<BagFuncResult> {
    try {
        // TODO: 实现具体逻辑
        let baseCom = player.getComponent(ComType.base) as base_component;
        baseCom.show = funcData.url;
        return {
            success: true,
            message: '形象更换成功',
            data: { action: 'ChangePlayerShow' }
        };
    } catch (error: any) {
        return {
            success: false,
            message: '功能执行失败',
            data: { error: error.message }
        };
    }
}
